VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form MMI 
   BackColor       =   &H00FFFFFF&
   Caption         =   "MMI"
   ClientHeight    =   2625
   ClientLeft      =   1830
   ClientTop       =   1590
   ClientWidth     =   5355
   Icon            =   "k1 MMI.frx":0000
   ScaleHeight     =   175
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   357
   Begin MSComDlg.CommonDialog fsel 
      Left            =   345
      Top             =   1815
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Timer PaceMaker 
      Enabled         =   0   'False
      Left            =   960
      Top             =   1860
   End
   Begin VB.Label RubBnd 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      BorderStyle     =   1  'Fixed Single
      Caption         =   "RubBnd"
      ForeColor       =   &H80000008&
      Height          =   495
      Left            =   345
      TabIndex        =   4
      Top             =   1080
      Visible         =   0   'False
      Width           =   1095
   End
   Begin VB.Label Led 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      ForeColor       =   &H80000008&
      Height          =   135
      Left            =   4740
      TabIndex        =   3
      ToolTipText     =   "Flashes at update rate when links running"
      Top             =   0
      Width           =   135
   End
   Begin VB.Label Desc 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BackStyle       =   0  'Transparent
      Caption         =   "Desc(0) - Desc obj."
      ForeColor       =   &H80000008&
      Height          =   195
      Index           =   0
      Left            =   2040
      TabIndex        =   2
      Top             =   225
      Visible         =   0   'False
      Width           =   1365
   End
   Begin VB.Label Disp 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Disp(0) - Display obj."
      ForeColor       =   &H80000008&
      Height          =   255
      Index           =   0
      Left            =   360
      TabIndex        =   1
      Top             =   195
      Visible         =   0   'False
      Width           =   1575
   End
   Begin VB.Label Link 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "Link(0) - Link obj."
      ForeColor       =   &H80000008&
      Height          =   255
      Index           =   0
      Left            =   360
      TabIndex        =   0
      Top             =   660
      Visible         =   0   'False
      Width           =   1575
   End
   Begin VB.Menu mnuObj 
      Caption         =   "Object Menu"
      Visible         =   0   'False
      Begin VB.Menu mnuObj_ 
         Caption         =   "Object Settings"
         Index           =   0
      End
      Begin VB.Menu mnuObj_ 
         Caption         =   "Duplicate"
         Index           =   1
      End
      Begin VB.Menu mnuObj_ 
         Caption         =   "Delete"
         Index           =   2
      End
      Begin VB.Menu mnuObj_ 
         Caption         =   "Bring to front"
         Index           =   3
      End
      Begin VB.Menu mnuObj_ 
         Caption         =   "Send to back"
         Index           =   4
      End
   End
   Begin VB.Menu mnuFrm 
      Caption         =   "Form Menu"
      Visible         =   0   'False
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Start Links"
         Index           =   1
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Write Enable"
         Enabled         =   0   'False
         Index           =   2
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Keep On Top"
         Index           =   3
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "-"
         Index           =   10
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "New"
         Index           =   11
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Save"
         Index           =   12
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Save as"
         Index           =   13
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Load"
         Index           =   14
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Obj File"
         Index           =   15
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "-"
         Index           =   20
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Settings"
         Index           =   21
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Info"
         Index           =   22
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "-"
         Index           =   30
      End
      Begin VB.Menu mnuFrm_ 
         Caption         =   "Exit"
         Index           =   31
      End
   End
End
Attribute VB_Name = "MMI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'========================================================================
'Lite MMI
'Main Form
'Global
'Form Load
'Form Unload
'Pacemaker Timer
'Mouse on DISP obj
'Mouse on Form
'Mouse on Desc obj
'Menu's
'Helpers
'========================================================================
'MMI - a place to display data.
'MMIset - database edit tool.
'MMIFrmSet - tool to set form properties.
'MMIWriteVal - a tool to write a new value.

Option Explicit
DefInt A-Z

'For OnTop
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
    ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
    ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'For OnTop
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOOWNERZORDER = &H200      '  Don't do owner Z ordering
Private Const SWP_NOSIZE = &H1

'For moving and resizing
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
        X As Long
        Y As Long
End Type
'Global Data for form
Dim RB_SelObjList() As Integer

Private Sub Form_Load()

    '1  Setup Form
        MMI.ScaleMode = SCLPIXEL
    
    '2  Initalize Layout Database (LAY) and autoload if selected
         LAYCtrl.aReset
         If Len(Trim(Command)) > 4 And UCase(Right(Trim(Command), 4)) = ".LAY" Then
            LAYCtrl.aLoad App.Path & "\" & Trim(Command)
            ReDrawLayout
    '3  Initalize Obj Database (VDT)
            VDTCtrl.Initalize
            VDTCtrl.LayoutLoad
         Else
            LAYCtrl.aLoad App.Path & "\" & App.EXEName & ".lay"
            If Not (LAY.AutoLoad = 1) Then LAYCtrl.aReset
            ReDrawLayout
    '3  Initalize Obj Database (VDT)
            VDTCtrl.Initalize
            If LAY.AutoLoad Then VDTCtrl.LayoutLoad
         End If
         
         Me.Show
    
    '3  Initalize Obj Database (VDT)
        
    '4  Setup File Selector and other controls on the form
        fsel.InitDir = App.Path
        fsel.Filter = "Layout files (*.lay)|*.lay|All files (*.*)|*.*"
        fsel.DefaultExt = "lay"
        
        RubBnd.Caption = ""
    
    '5 Set the update cycle time
        PaceMaker.Interval = 1000   '1 sec
        PaceMaker.Enabled = True
        
    '6  Start links if set to autostart
        If LAY.AutoStart = 1 Then MMI_LinksStart
        
        
End Sub

'UNLOAD FORM
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If LAY.AutoSave Then
        LAYCtrl.aSave
        VDTCtrl.LayoutSave
    End If
End Sub

'PACEMAKER TIMER
Private Sub PaceMaker_Timer()
        If Vdt.LinkRun Then
            LinkUD.ddeLinkUpDate
            If Led.BackColor = vbGreen Then
                Led.BackColor = vbWhite
            Else
                Led.BackColor = vbGreen
            End If
        Else
            Led.BackColor = vbWhite
        End If
        Led.Left = Me.ScaleWidth - Led.Width
End Sub

'-----------------------------------
'   MOUSE ON DISPLAY OBJECT
'-----------------------------------
Private Sub Disp_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Not Vdt.ModeRun Then
        Select Case Button
            Case vbLeftButton
                DISPmove Disp(Index), True
            Case vbRightButton
                Vdt.Index = Index
                PopupMenu mnuObj
        End Select
    End If
End Sub

Private Sub Disp_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Not Vdt.ModeRun And Button = vbLeftButton Then DISPmove Disp(Index), False
End Sub

Private Sub Disp_Click(Index As Integer)
    If Vdt.LinkRun And Vdt.ModeRun And Vdt.Item(Index).Writable Then
      If Vdt.Item(Index).Type <> 3 Then
         Vdt.Index = Index: MMIWriteVal.Show
      Else
         DoLMMI (Index)
      End If
   End If
End Sub

Private Sub DoLMMI(Index)
   
   On Error GoTo shellerr
   Dim cmdstr As String
   Dim cmd As String
   Dim cmddata As String
   Dim sliceat As Long
   
   cmdstr = Trim(Vdt.Item(Index).LinkWriteItem)
   sliceat = InStr(cmdstr, " ")
   cmd = UCase(Left(cmdstr, sliceat - 1))
   cmddata = Mid(cmdstr, sliceat + 1)
   
   Select Case cmd
      Case "OPEN"
         If InStr(cmddata, ".lay") > 0 Then
            Shell App.EXEName & " " & cmddata, vbNormalFocus
         Else
            Shell App.EXEName & " " & cmddata & ".lay", vbNormalFocus
         End If
      Case "EXE"
            Shell cmddata, vbNormalFocus
   End Select
   
      
   Exit Sub
shellerr:
   MsgBox "Tried to launch..." & vbNewLine & _
            App.Path & "\" & Trim(Vdt.Item(Index).LinkWriteItem) & vbNewLine & _
            "but it failed with the following error..." & vbNewLine & vbNewLine & _
            Err.Description
   Resume Next
End Sub

Private Sub Disp_DblClick(Index As Integer)
    If Not Vdt.LinkRun Or Not Vdt.ModeRun Then Vdt.Index = Index: mnuObj__Click 0
End Sub

'-----------------------------------
'   Move Disp Obj
'-----------------------------------
Private Sub DISPmove(movOBJ As Object, mDown As Boolean)
    Static Xos As Integer
    Static Yos As Integer
    Static XosToDesc As Integer
    Static YosToDesc As Integer
    Dim mousePT As POINTAPI
    Call GetCursorPos(mousePT)
    If mDown Then
        Xos = mousePT.X - movOBJ.Left
        Yos = mousePT.Y - movOBJ.Top
        XosToDesc = Desc(movOBJ.Index).Left - movOBJ.Left
        YosToDesc = Desc(movOBJ.Index).Top - movOBJ.Top
    Else
        If LAY.Snap Then
            movOBJ.Left = Int((mousePT.X - Xos) / LAY.SnapX) * LAY.SnapX
            movOBJ.Top = Int((mousePT.Y - Yos) / LAY.SnapY) * LAY.SnapY
        Else
            movOBJ.Left = (mousePT.X - Xos)
            movOBJ.Top = (mousePT.Y - Yos)
        End If
        Desc(movOBJ.Index).Left = movOBJ.Left + XosToDesc
        Desc(movOBJ.Index).Top = movOBJ.Top + YosToDesc
    End If
End Sub

'-----------------------------------
'   MOUSE ON THE FORM (MMI)
'-----------------------------------
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbRightButton Then Me.PopupMenu mnuFrm
    If Button = vbLeftButton And Not Vdt.ModeRun Then RB_DrawSQ 1, X, Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton And Not Vdt.ModeRun Then RB_DrawSQ 2, X, Y
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RB_DrawSQ 3, X, Y
End Sub

Private Sub RB_DrawSQ(MouseStep As Integer, X As Single, Y As Single)
'Rubber Band / ReSizer Routine
    Const Xmin = 5 'min sq size
    Const Ymin = 5 'min sq size
    Static Xos As Integer 'offset between mouse and form
    Static Yos As Integer 'offset between mouse and form
    Static Xs As Integer 'X at start
    Static Ys As Integer 'Y at start
    Dim M As POINTAPI: Call GetCursorPos(M) 'get the mouse pos
    With RubBnd
        .BorderStyle = 1
        Select Case MouseStep
            Case 1 'MouseDown
                Xs = X: Ys = Y: Xos = M.X - Xs: Yos = M.Y - Ys
                .Left = M.X - Xos
                .Top = M.Y - Yos
                .Width = Xmin
                .Height = Ymin
                .Visible = True
            Case 2 'Mouse Move
                If M.X - Xos > Xs Then .Width = M.X - Xos - .Left Else .Left = M.X - Xos: .Width = Xs - .Left
                If M.Y - Yos > Ys Then .Height = M.Y - Yos - .Top Else .Top = M.Y - Yos: .Height = Ys - .Top
            Case 3 'Mouse Up
                rb_selobj
        End Select
    End With
End Sub

'-----------------------------------
'   MOUSE ON THE DESC OBJ
'-----------------------------------
Private Sub Desc_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
        Call DESCmove(Desc(Index), True)
    End If
End Sub

Private Sub Desc_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then
        Call DESCmove(Desc(Index), False)
    End If
End Sub

Private Sub DESCmove(movOBJ As Object, mDown As Boolean)
    Static Xos As Integer
    Static Yos As Integer
    Dim mousePT As POINTAPI
    Call GetCursorPos(mousePT)
    If mDown Then
        Xos = mousePT.X - movOBJ.Left
        Yos = mousePT.Y - movOBJ.Top
    Else
        If LAY.Snap Then
            movOBJ.Left = Int((mousePT.X - Xos) / LAY.SnapX) * LAY.SnapX + LAY.DescXos
            movOBJ.Top = Int((mousePT.Y - Yos) / LAY.SnapY) * LAY.SnapY + LAY.DescYos
        Else
            movOBJ.Left = (mousePT.X - Xos)
            movOBJ.Top = (mousePT.Y - Yos)
        End If
    End If
End Sub

'------------------------------
'   MENUS
'------------------------------
Private Sub mnuFrm__Click(Index As Integer)
    Select Case Index

        Case 1 'Start/Stop Links
            If Vdt.LinkRun Then
                MMI_LinksStop
            Else
                MMI_LinksStart
            End If

        Case 2 'Write/Edit Mode
            If Vdt.ModeRun Then
                MMI_WriteDisable
            Else
                MMI_WriteEnable
            End If
        
        Case 3 'Ontop
            Const winFlags = SWP_SHOWWINDOW + SWP_NOMOVE + SWP_NOSIZE
            Static OnTop As Boolean
            If Not OnTop Then
                SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, winFlags
                OnTop = True
                mnuFrm_(3).Caption = "Not On Top"
            Else
                SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, winFlags
                OnTop = False
                mnuFrm_(3).Caption = "Keep On Top"
            End If
        '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
        Case 11 'New
            MMI_LinksStop
            LAYCtrl.aReset
            VDTCtrl.Initalize
            ReDrawLayout
        
        Case 12 'Save
                LAYCtrl.aSave
                VDTCtrl.LayoutSave
        
        Case 13 'Save As
            fsel.ShowSave
            If fsel.FileName <> "" Then
                LAY.LayFileName = fsel.FileName
                LAY.ObjFileName = Left(LAY.LayFileName, Len(LAY.LayFileName) - 4) & ".obj"
                LAYCtrl.aSave
                VDTCtrl.LayoutSave
            End If
        
        Case 14 'Load
            fsel.ShowOpen
            If fsel.FileName <> "" Then
                MMI_LinksStop
                LAYCtrl.aLoad fsel.FileName
                ReDrawLayout
                VDTCtrl.Initalize
                VDTCtrl.LayoutLoad
            End If
        
        Case 15 'Open obj file
            On Error Resume Next
            Shell "notepad.exe " & LAY.ObjFileName, vbNormalFocus
            Open LAY.ObjFileName For Input As #1
            Dim ObjFileClip As String
            Dim ObjFileClipBuf As String
            While Not EOF(1)
                Line Input #1, ObjFileClipBuf
                ObjFileClip = ObjFileClip & ObjFileClipBuf
                If Not EOF(1) Then ObjFileClip = ObjFileClip & vbNewLine
            Wend
            Close #1
            Clipboard.SetText (ObjFileClip)
            On Error GoTo 0

        '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
        Case 21 'settings
            MMIFrmSet.Show vbModal, Me ' settings
        
        Case 22  'Show LAY
            LAYCtrl.aShow
        '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
        Case 31  'Exit
            Unload Me
    
    End Select
End Sub

Private Sub mnuObj__Click(Index As Integer)
    Select Case Index
        Case 0: MMIset.Show vbModal, Me
        Case 1: objClone
        Case 2: objDelete
        Case 3: objToFront
        Case 4: objToBack
    End Select
    Vdt.Index = -1
End Sub

'Restore Layout to the MMI form
Private Sub ReDrawLayout()
    MMI.Caption = LAY.Title
    MMI.BackColor = LAY.BackColor
    Select Case LAY.WinState
        Case 0 'Normal
            MMI.WindowState = WINNORM
            MMI.Left = LAY.Left
            MMI.Top = LAY.Top
            MMI.Width = LAY.Width
            MMI.Height = LAY.Height
        Case 1 'Min
            MMI.WindowState = WINNORM
            MMI.Left = Screen.Width * 0.1
            MMI.Top = Screen.Height * 0.1
            MMI.Width = Screen.Width * 0.7
            MMI.Height = Screen.Height * 0.7
        Case 2 'Max
            MMI.WindowState = WINNORM
            MMI.Left = Screen.Width * 0.1
            MMI.Top = Screen.Height * 0.1
            MMI.Width = Screen.Width * 0.7
            MMI.Height = Screen.Height * 0.7
            MMI.WindowState = WINMAX
    End Select
End Sub

Sub MMI_LinksStart()
    'Do all the things needed to start the ddelinks
    mnuFrm_(1).Caption = "Stop Links"
    LinkUD.ddeLinksStart
    Vdt.LinkRun = True
    mnuFrm_(2).Enabled = True
End Sub

Sub MMI_LinksStop()
    'Do all the things needed to stop the ddelinks
    LinkUD.ddeLinksStop
    Vdt.LinkRun = False
    mnuFrm_(1).Caption = "Start Links"
    MMI_WriteDisable
    mnuFrm_(2).Enabled = False
End Sub

Sub MMI_WriteEnable()
    'Do all the things needed to goto Write Enable Mode
    mnuFrm_(2).Caption = "Write Disable"
    Vdt.ModeRun = True
    Me.Caption = Me.Caption & " [Write]"
End Sub

Sub MMI_WriteDisable()
    'Do all the things needed to goto Write Disabled Mode
    mnuFrm_(2).Caption = "Write Enable"
    Vdt.ModeRun = False
    If Right(Me.Caption, 8) = " [Write]" Then Me.Caption = Left(Me.Caption, Len(Me.Caption) - 8)
End Sub

Private Sub RubBnd_Click()
    RubBnd.Visible = False
End Sub

Private Sub RubBnd_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RB_MovObj 0
End Sub

Private Sub RubBnd_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = vbLeftButton Then RB_MovObj 1
End Sub

Private Sub RubBnd_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RB_MovObj 2
End Sub

Private Sub rb_selobj()
'Positions the ruberband around the selected objects

    Dim pT As Integer
    Dim rbL, rbT, rbB, rbR As Long
    Dim L, T, R, B As Long
    Dim TL As Integer
    Dim BR As Integer
    Dim HL, HT, HR, HB As Long
    ReDim RB_SelObjList(0 To 0)
    RB_SelObjList(0) = 0
    
    HL = -1
    HT = -1
    
    'get the rubberband
    rbL = RubBnd.Left: rbR = rbL + RubBnd.Width
    rbT = RubBnd.Top: rbB = rbT + RubBnd.Height
    
    
    For pT = 1 To Vdt.Count
        'get the objs
        L = Disp(pT).Left
        T = Disp(pT).Top
        R = L + Disp(pT).Width
        B = T + Disp(pT).Height
        
        'check for obj inside rubberband
        If L >= rbL And R <= rbR And T >= rbT And B <= rbB Then
            If HL = -1 Then HL = L
            If HT = -1 Then HT = T
            If L < HL Then HL = L
            If T < HT Then HT = T
            If R > HR Then HR = R
            If B > HB Then HB = B
            RB_SelObjList(0) = RB_SelObjList(0) + 1
            ReDim Preserve RB_SelObjList(0 To RB_SelObjList(0))
            RB_SelObjList(RB_SelObjList(0)) = pT
        End If
    Next
        RubBnd.Left = HL
        RubBnd.Width = HR - HL
        RubBnd.Top = HT
        RubBnd.Height = HB - HT
        RubBnd.BackColor = vbYellow
        RubBnd.ZOrder
        
End Sub

Private Sub RB_MovObj(MouseButtonState As Integer)

    '0 = Down
    '1 = Moving
    '2 = Up
    
    Static Xos As Integer
    Static Yos As Integer
    
    Dim newRBX As Integer
    Dim newRBY As Integer
    Dim RBXos As Integer
    Dim RBYos As Integer
    Dim pT As Integer
    Dim SelObj As Integer
    
    Dim mousePT As POINTAPI
    Call GetCursorPos(mousePT)
    
    Select Case MouseButtonState
    
        Case 0 'Button down
            Xos = mousePT.X - RubBnd.Left
            Yos = mousePT.Y - RubBnd.Top
            
        Case 1 'Moving
            If LAY.Snap Then
                newRBX = Int((mousePT.X - Xos) / LAY.SnapX) * LAY.SnapX
                newRBY = Int((mousePT.Y - Yos) / LAY.SnapY) * LAY.SnapY
            Else
                newRBX = (mousePT.X - Xos)
                newRBY = (mousePT.Y - Yos)
            End If
            
            'test for limits
            If newRBX < 0 Then newRBX = 0
            If newRBY < 0 Then newRBY = 0
            
            If LAY.Snap Then
                If newRBX + RubBnd.Width > Me.ScaleWidth Then newRBX = Int((Me.ScaleWidth - RubBnd.Width) / LAY.SnapX) * LAY.SnapX
                If newRBY + RubBnd.Height > Me.ScaleHeight Then newRBY = Int((Me.ScaleHeight - RubBnd.Height) / LAY.SnapY) * LAY.SnapY
            Else
                If newRBX + RubBnd.Width > Me.ScaleWidth Then newRBX = Me.ScaleWidth - RubBnd.Width
                If newRBY + RubBnd.Height > Me.ScaleHeight Then newRBY = Me.ScaleHeight - RubBnd.Height
            End If
            'repositon the rubberband
            RBXos = newRBX - RubBnd.Left
            RBYos = newRBY - RubBnd.Top
            RubBnd.Move RBXos + RubBnd.Left, RBYos + RubBnd.Top
                
            'now reposition the objects
            If RBXos <> 0 Or RBYos <> 0 Then
                For pT = 1 To RB_SelObjList(0)
                    SelObj = RB_SelObjList(pT)
                    Disp(SelObj).Move RBXos + Disp(SelObj).Left, RBYos + Disp(SelObj).Top
                    Desc(SelObj).Move RBXos + Desc(SelObj).Left, RBYos + Desc(SelObj).Top
                Next
            End If
        
        Case 2 'Button up
            RubBnd.Visible = False
            ReDim RB_SelObjList(0 To 0)
            
    End Select
End Sub
